#include "exv_drv.h"

static void exv10_OneStep(uint16_t step);
static void exv11_OneStep(uint16_t step);
static void exv20_OneStep(uint16_t step);
static void exv21_OneStep(uint16_t step);
static void exv30_OneStep(uint16_t step);
static void exv31_OneStep(uint16_t step);
static void exv40_OneStep(uint16_t step);
static void exv41_OneStep(uint16_t step);

void SetExvStep(exvNum_t num, uint16_t step)
{
    if(num == exvM1)	    exv10_OneStep(step);
    else if(num == exvS1)  exv11_OneStep(step);
    else if(num == exvM2)  exv20_OneStep(step);
    else if(num == exvS2)  exv21_OneStep(step);
    else if(num == exvM3)  exv30_OneStep(step);
    else if(num == exvS3)  exv31_OneStep(step);
    else if(num == exvM4)  exv40_OneStep(step);
    else if(num == exvS4)  exv41_OneStep(step);
}

void StopExv(exvNum_t num)
{
    if(num == exvM1)	   STEP10_N();
    else if(num == exvS1)  STEP11_N();
    else if(num == exvM2)  STEP20_N();
    else if(num == exvS2)  STEP21_N();
    else if(num == exvM3)  STEP30_N();
    else if(num == exvS3)  STEP31_N();
    else if(num == exvM4)  STEP40_N();
    else if(num == exvS4)  STEP41_N();
}

static void exv10_OneStep(uint16_t step)
{
    switch(step % 8)
    {
	    case 0:	    
			STEP10A();break;				    
	    case 1:	    
			STEP10AB(); break;				    
	    case 2:	    
			STEP10B();break;				    
	    case 3:
			STEP10BC();break;			
	    case 4:
			STEP10C();break;
	    case 5:
			STEP10CD();break;
	    case 6:	    
			STEP10D();break;			
	    case 7:
			STEP10DA();break;
	}     
}

static void exv11_OneStep(uint16_t step)
{
    switch(step % 8)
    {
	    case 7:	    
			STEP11A();break;				    
	    case 6:	    
			STEP11AB(); break;				    
	    case 5:	    
			STEP11B();break;				    
	    case 4:
			STEP11BC();break;			
	    case 3:
			STEP11C();break;
	    case 2:
			STEP11CD();break;
	    case 1:	    
			STEP11D();break;			
	    case 0:
			STEP11DA();break;
	}     
}

static void exv20_OneStep(uint16_t step)
{
    switch(step % 8)
    {
	    case 7:	    
			STEP20A();break;				    
	    case 6:	    
			STEP20AB(); break;				    
	    case 5:	    
			STEP20B();break;				    
	    case 4:
			STEP20BC();break;			
	    case 3:
			STEP20C();break;
	    case 2:
			STEP20CD();break;
	    case 1:	    
			STEP20D();break;			
	    case 0:
			STEP20DA();break;
	}     
}

static void exv21_OneStep(uint16_t step)
{
    switch(step % 8)
    {
	    case 7:	    
			STEP21A();break;				    
	    case 6:	    
			STEP21AB(); break;				    
	    case 5:	    
			STEP21B();break;				    
	    case 4:
			STEP21BC();break;			
	    case 3:
			STEP21C();break;
	    case 2:
			STEP21CD();break;
	    case 1:	    
			STEP21D();break;			
	    case 0:
			STEP21DA();break;
	}     
}

static void exv30_OneStep(uint16_t step)
{
    switch(step % 8)
    {
	    case 7:	    
			STEP30A();break;				    
	    case 6:	    
			STEP30AB(); break;				    
	    case 5:	    
			STEP30B();break;				    
	    case 4:
			STEP30BC();break;			
	    case 3:
			STEP30C();break;
	    case 2:
			STEP30CD();break;
	    case 1:	    
			STEP30D();break;			
	    case 0:
			STEP30DA();break;
	}     
}

static void exv31_OneStep(uint16_t step)
{
    switch(step % 8)
    {
	    case 7:	    
			STEP31A();break;				    
	    case 6:	    
			STEP31AB(); break;				    
	    case 5:	    
			STEP31B();break;				    
	    case 4:
			STEP31BC();break;			
	    case 3:
			STEP31C();break;
	    case 2:
			STEP31CD();break;
	    case 1:	    
			STEP31D();break;			
	    case 0:
			STEP31DA();break;
	}     
}

static void exv40_OneStep(uint16_t step)
{
    switch(step % 8)
    {
	    case 7:	    
			STEP40A();break;				    
	    case 6:	    
			STEP40AB(); break;				    
	    case 5:	    
			STEP40B();break;				    
	    case 4:
			STEP40BC();break;			
	    case 3:
			STEP40C();break;
	    case 2:
			STEP40CD();break;
	    case 1:	    
			STEP40D();break;			
	    case 0:
			STEP40DA();break;
	}     
}

static void exv41_OneStep(uint16_t step)
{
    switch(step % 8)
    {
	    case 7:	    
			STEP41A();break;				    
	    case 6:	    
			STEP41AB(); break;				    
	    case 5:	    
			STEP41B();break;				    
	    case 4:
			STEP41BC();break;			
	    case 3:
			STEP41C();break;
	    case 2:
			STEP41CD();break;
	    case 1:	    
			STEP41D();break;			
	    case 0:
			STEP41DA();break;
	}     
}
